Results 1 to 4 of 4

Thread: Adding hex segments and offsets

  1. #1

    Thread Starter
    Frenzied Member markman's Avatar
    Join Date
    Nov 2000
    Location
    Florida.
    Posts
    1,197

    Adding hex segments and offsets

    Code:
    MOV   AX, 0     ; AX = 0
    MOV   AL, 0     ; AL = 0
    MOV   AH, 0     ; AH = 0
    
    MOV   AL, FFh   ; AL = FFh
      ; AX = 00FFh
      ; AH = 00h
    ;I understand up to here
    INC   AX        ; AX = AX + 1
      ; AX = 0100h
      ; AH = 01h
      ; AL = 00h
    ;but not this. I thought that:
    ;   since AL (FFh) + 1  = 100
    ;   and AH (00h) +1 = 01h
    ;   that AH|AL would be 01|100, but it should be 0100h. What am I missing?
    retired member. Thanks for everything

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Code:
    Since AH and AL form the AX register together you have
    ; start
    mov ax, 0
    ; AX: 00 00h
    ;     AH AL
    mov al, 0
    mov ah, 0
    ; those were both redundant, since they are already 0
    
    mov al, FFh
    ; AX: 00 FFh
    ;     AH AL
    
    inc ax
    ; AX: 01 00h
    ;     AH AL
    
    ; AL cannot hold more than FFh
    It's a little bit confusing, but AX is not an independent register but only the merger of AH and AL.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3
    Fanatic Member
    Join Date
    Jan 2003
    Posts
    1,004
    Has this been resolved?
    "Can't" and "shouldn't" are two totally separate things.

    All questions should be answered. All answers should be true. That is why I post.

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    I think it has, but I never heard from the poster again.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width